import {ModuleWithProviders} from '@angular/core';

import {Routes, RouterModule} from '@angular/router';
import {GenerateTestComponent} from '../routes/generate-test/generate-test.component';
import {HomeComponent} from '../routes/home/home.component';
import {LoginComponent} from '../routes/login/login.component';
import {DashboardComponent} from '../routes/dashboard/dashboard.component';
import {UserComponent} from '../routes/user/user.component';
import {CanAuthProvide} from '@core/services/auth.service';
import {ChartsComponent} from './charts/charts.component';
import {QuestionListComponent} from './question/list/list.component';
import {QuestionTypeComponent} from './question/question_type/question_type.component';
import {TestRecordComponent} from './test-record/test-record.component';

export const routes: Routes = [
  {path: 'login', component: LoginComponent, canLoad: [CanAuthProvide]},
  {
    path: '', component: HomeComponent, canActivate: [CanAuthProvide],
    children: [
      {
        path: 'generateTest', component: GenerateTestComponent, canActivate: [CanAuthProvide],
        data: {
          breadcrumb: '生成试卷'
        }
      },
      {
        path: 'question/list', component: QuestionListComponent, canActivate: [CanAuthProvide],
        data: {
          breadcrumb: '题库列表'
        }
      },
      {
        path: 'question/type', component: QuestionTypeComponent, canActivate: [CanAuthProvide],
        data: {
          breadcrumb: '题库分类'
        }
      },
      {
        path: 'testrecord', component: TestRecordComponent, canActivate: [CanAuthProvide],
        data: {
          breadcrumb: '答题记录'
        }
      },
      {
        path: 'user', component: UserComponent, canActivate: [CanAuthProvide],
        data: {
          breadcrumb: '用户'
        }
      },
      {path: 'charts', component: ChartsComponent, canActivate: [CanAuthProvide]},
      {path: '', redirectTo: 'generateTest', pathMatch: 'full'}
    ]
  },
  {path: '**', redirectTo: '/', pathMatch: 'full'},
];

